import Vue from 'vue'

export default {
	namespaced: true,
	state: {
		action: '', // 动作
		taskInfo: {}, // 任务
		recordInfo: {}, // 记录
		isLT200m: false // 是否小于 200 米
	},
	mutations: {
		setAction(state, payload) {
			state.action = payload
		},
		setTaskInfo(state, payload) {
			state.taskInfo = payload
		},
		resetTaskInfo(state) {
			state.taskInfo = {
				"id": null,
				"projectId": null,
				"orgId": null,
				"year": '',
				"samplingType": '',
				"taskStatus": '',
				"code": '',
				"positionType": '',
				"province": null,
				"city": null,
				"county": null,
				"town": '',
				"village": '',
				"team": '',
				"landUse": '',
				"wgs84Longitude": '',
				"wgs84Latitude": '',
				"wgs84Altitude": '',
				"gcj02Longitude": '',
				"gcj02Latitude": '',
				"soilType": '',
				"protectionStrategy": '',
				"soilClass": '',
				"subClass": '',
				"soilMaterial": '',
				"mainCrop": '',
				"cropType": '',
				"provinceName": '',
				"cityName": '',
				"countyName": '',
				'cropTypeManual':''
			}
		},
		setTaskInfoAttr(state, payload) {
			Vue.set(state.taskInfo, payload.key, payload.val)
		},
		setRecordInfo(state, payload) {
			state.recordInfo = payload
		},
		resetRecordIno(state) {
			state.recordInfo = {
				"id": null,
				"projectId": null,
				"taskId": null,
				"samplingTime": '',
				"autoProvinceCityCounty": false,
				"autoLngLat": false,
				"screenLongitude": '',
				"screenLatitude": '',
				"screenAltitude": '',
				"nitrogen": '',
				"phosphate": '',
				"potassium": '',
				"organic": '',
				"compound": '',
				"eastInfo": '',
				"southInfo": '',
				"westInfo": '',
				"northInfo": '',
				"waterSourceInfo": '',
				"disasterInfo": '',
				"otherInfo": '',
				"eastImage": '',
				"southImage": '',
				"westImage": '',
				"northImage": '',
				"centerGps": '',
				"waterSourceImage": '',
				"disasterImage": '',
				"otherImage": '',
				"soilSamplingCode": '',
				"samplingDepth": '',
				"sampleWeight": '',
				"soilSamplingSceneImage": '',
				"soilSamplePackageImage": '',
				"soilBag2Label2Image": '',
				"soilOtherImage": '',
				"cropSamplingCode": '',
				"cropName": '',
				"cropWeight": '',
				"quarterProduction": '',
				"cropSamplingSceneImage": '',
				"cropSamplePackageImage": '',
				"cropBag2Label2Image": '',
				"cropOtherImage": '',
				"comment": '',
			}
		},
		setRecordInfoAttr(state, payload) {
			Vue.set(state.recordInfo, payload.key, payload.val)
		},
		setIsLT200m(state, payload) {
			state.isLT200m = payload
		},
		clearCjRecord(state) {
			state.action = ''
			state.taskInfo = {}
			state.recordInfo = {}
			state.isLT200m = false
		}
	}
}